package handlers

import (
	"MessageSendService/app/common/enum/channalType"
	"sync"
)

var (
	handlerHolder map[channalType.ChannalType]Ihandler
	once          sync.Once
)

// SetUp 设置并初始化消息处理器
func SetUp() {
	once.Do(func() {
		handlerHolder = make(map[channalType.ChannalType]Ihandler)
		handlerHolder[channalType.Sms] = NewSmsHandler()
		handlerHolder[channalType.Email] = NewEmailHandler()
	})
}

func GetHandler(channel channalType.ChannalType) Ihandler {
	return handlerHolder[channel]
}
